﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Directory.Web
{
    /// <summary>
    /// RoleDataProxy 的摘要说明
    /// </summary>
    public sealed class RoleDataProxy
    {
        private RoleDataProxy() { }

		public static bool TryDeleteRole(string rolename)
		{
			Directory.BLL.Role bll = new Directory.BLL.Role();
			return bll.DeleteRole(rolename, true);
		}

		public static void CreateRole(string rolename, string description, out Directory.Model.RoleInfo.ErrorCode ErrorCode)
		{
			Directory.BLL.Role bll = new Directory.BLL.Role();
			bll.CreateRole(rolename, description, out ErrorCode);
		}

		public static string[] GetAllRoles(int pageIndex, int pageSize, out int totalRecords)
        {
            Directory.BLL.Role bll = new Directory.BLL.Role();
            return bll.GetAllRoles(pageIndex,pageSize,out totalRecords);
        }

		public static string[] GetUsersInRole(string rolename, int pageIndex, int pageSize, out int totalRecords)
        {
            Directory.BLL.Role bll = new Directory.BLL.Role();
            return bll.GetUsersInRole(rolename,pageIndex,pageSize,out totalRecords);
        }

		public static bool IsUserInRole(string username, string rolename)
        {
			Directory.BLL.Role bll = new Directory.BLL.Role();
			return bll.IsUserInRole(username, rolename);
        }

		public static string[] GetRolesForUser(string username, int pageIndex, int pageSize, out int totalRecords)
		{
			Directory.BLL.Role bll = new Directory.BLL.Role();
			return bll.GetRolesOfUser(username, pageIndex, pageSize, out totalRecords);
		}

		public static void AddUserToRole(string username, string rolename)
		{
			Directory.BLL.Role bll = new Directory.BLL.Role();
			bll.AddUserToRole(username, rolename);
		}

		public static void RemoveUserFromRole(string username, string rolename)
		{
			Directory.BLL.Role bll = new Directory.BLL.Role();
			bll.RemoveUserFromRole(username, rolename);
		}
    }
}
